package com.disgruntledbots;

import org.andengine.extension.physics.box2d.PhysicsFactory;
import org.andengine.extension.physics.box2d.PhysicsWorld;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;

public class CircularBodyEntityConnector extends PhysicsEntityConnector {
	
	public CircularBodyEntityConnector(float X, float Y, ITextureRegion texture, VertexBufferObjectManager vbom, PhysicsWorld pWorld, 
			float mass, float elasticity, float friction)
	{
		super(X, Y, texture, vbom, pWorld, mass, elasticity, friction);
	}
	
	@Override
	protected float getDensity(float mass)
	{
		double radius = (double)super.mSprite.getWidth() * 0.5;
		float area = (float)(Math.PI * radius * radius);
		float density = area / mass;
		
		return density;
	}
	
	@Override
	protected void createBody(PhysicsWorld pWorld, FixtureDef fixDef)
	{
		this.mBody = PhysicsFactory.createCircleBody(pWorld, this.mSprite, BodyType.DynamicBody, fixDef);
	}
}
